﻿namespace Xc.DataAccess.Protocoals.WaterMeters.Models
{
    /// <summary>
    /// 表具状态
    /// </summary>
    public class MeterStatus
    {
        protected MeterStatus()
        {

        }
        public MeterStatus(byte[] vs)
        {
            var b1=vs[0];
            var c1 = b1 & 0b0000_0011;
            ValveState = (ValveState)c1;
            BatteryState = (BatteryState)((byte)(b1 >> 2) & 0b0000_0001);
            ReedStatus = (ReedStatus)((byte)(b1 >> 3) & 0b0000_0011);
            OpenValueState = (OpenValueState)((byte)(b1 >> 4) & 0b0000_0001);
            MeterError = (MeterError)vs[1];
        }
        /// <summary>
        /// 阀门状态
        /// </summary>
        public ValveState ValveState { get; set; }
        /// <summary>
        /// 电池状态
        /// </summary>
        public BatteryState BatteryState { get; set; }
        /// <summary>
        /// 干簧管状态
        /// </summary>
        public ReedStatus ReedStatus { get; set; }
        /// <summary>
        /// 开阀状态
        /// </summary>
        public OpenValueState OpenValueState { get; set; }
        /// <summary>
        /// 表计上报的错误
        /// </summary>
        public MeterError MeterError { get; set; }
    }
}
